<template>
<!-- 查询结果 -->
<div>
  <el-table :data="searchresult" border style="width: 90%">
    <el-table-column type="index" width="80">
    </el-table-column>
    <el-table-column prop="SALEDETAILNO" label="保险单号" width="250">
    </el-table-column>
    <el-table-column prop="ORGNAME" label="保险销售机构名称" width="200">
    </el-table-column>
    <el-table-column prop="CUSTNAME" label="被保险人姓名" width="150">
    </el-table-column>
    <el-table-column prop="PASSPORTNUMBER" label="护照号码" width="150">
    </el-table-column>
    <el-table-column prop="BIRTHDAY" label="出生日期" width="150" :formatter="localDataFomatter">
    </el-table-column>
    <el-table-column prop="PRODUCTNAME" label="产品类型" width="150">
    </el-table-column>
    <el-table-column prop="CERTDATE" label="保险责任开始时间" width="150"  :formatter="localDataFomatter">
    </el-table-column>
    <el-table-column prop="STATUS" label="状态" width="100">
    </el-table-column>
    <!-- <el-table-column prop="PRODUCTNO" label="套餐编号" width="100">
    </el-table-column> -->
    <el-table-column label="操作" width="100">
      <template scope="scope">
        <el-button type="text" size="media" @click="goform(scope.row.SALEDETAILNO)">
          <i class="el-icon-edit"> 查看</i>
        </el-button>
      </template>

    </el-table-column>
  </el-table>
    <el-dialog title="保单查看" :visible.sync="show"  size="large">
                <policy-show :type="'保单查看'" >
                </policy-show>
        </el-dialog>
</div>
</template>
<script>
import PolicyShow from "@/components/Sell/policyShow";
import api from "@/js/api";

import { mapState } from "vuex";
export default {
  data() {
    return {
      show: false
    };
  },
  props: {
    searchresult: {
      type: Array,
      default: []
    }
  },
  components: {
    "policy-show": PolicyShow
  },
  computed: mapState({
    saleDetail: state => state.SealDetail.model
  }),
  methods: {
    localDataFomatter(row, column, cellValue) {
      cellValue = cellValue + "Z";
      var data = new Date(cellValue);
      var dataString =
        data.getFullYear() +
        "/" +
        (data.getMonth() + 1 >= 10
          ? data.getMonth() + 1
          : "0" + (data.getMonth() + 1)) +
        "/" +
        (data.getDate() >= 10 ? data.getDate() : "0" + data.getDate());
      // " " +
      // (data.getHours() >= 10 ? data.getHours() : "0" + data.getHours()) +
      // ":" +
      // (data.getMinutes() >= 10 ? data.getMinutes() : "0" + data.getMinutes());
      return dataString;
    },
    goform(id) {    
      let that = this;
      api.SaledetailGetDtoOne(that, { id: id }, function(msg) {
        var cloneObj = msg.Result;
        if (cloneObj.SALESDETAIL.SALESDETAIL_APPLYTIME)
          cloneObj.SALESDETAIL.SALESDETAIL_APPLYTIME =
            cloneObj.SALESDETAIL.SALESDETAIL_APPLYTIME + "Z";
        if (cloneObj.SALESDETAIL.SALESDETAIL_STARTTIME)
          cloneObj.SALESDETAIL.SALESDETAIL_STARTTIME =
            cloneObj.SALESDETAIL.SALESDETAIL_STARTTIME + "Z";
        if (cloneObj.SALESDETAIL.SALESDETAIL_ENDTIME)
          cloneObj.SALESDETAIL.SALESDETAIL_ENDTIME =
            cloneObj.SALESDETAIL.SALESDETAIL_ENDTIME + "Z";      
        that.$store.commit("changer", cloneObj.SALESDETAIL);
        that.saleDetail.CUSTOM = cloneObj.CUSTOM;
        that.saleDetail.RELATIONPEOPLEs = cloneObj.SALESDETAIL.RELATIONPEOPLEs;
        that.saleDetail.QUESTION = cloneObj.SALESDETAIL.QUESTION;
          that.show = true;
      });
    }
  }
};
</script>